class FactorialOfTen implements Runnable {
    private int result;
    static final int N = 10;

    static public void main(String args[]) throws Exception {
        Thread test = new Thread(new FactorialOfTen());
        test.start();
        System.out.println("Main Thread starts to sleep for 5 secs.");
        Thread.sleep(5000);
        System.out.println("Main Thread wake up.");
    }

    public void run() {
        System.out.println("Sub-Thread starts to sleep for 2 secs.");
        try {
            Thread.sleep(2000);
        } catch (Exception e) {
        }
        System.out.println("Sub-Thread wake up.");
        result = 1;
        for (int i = 1; i <= N; ++ i) {
            result *= i;
        }

        System.out.println("Factorial of ten is: " + String.valueOf(result));
    }
}
